﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Microsoft.VisualBasic;

namespace SalePartial.Model
{

    public class XPRatingInfo
    {
        // Methods
        public XPRatingInfo()
        {
            this._ratingTargetID = Guid.Empty;
            this._ratingOwnerID = Guid.Empty;
            this._ratingUserID = Guid.Empty;
            this._ratingComment = string.Empty;
            this._ratingID = Guid.NewGuid();
            this._ratingDate = DateTime.Now;
        }

        public XPRatingInfo(SqlDataReader reader)
        {
            this._ratingTargetID = Guid.Empty;
            this._ratingOwnerID = Guid.Empty;
            this._ratingUserID = Guid.Empty;
            this._ratingComment = string.Empty;
            this.LoadFromReader(reader);
        }

        //public XPRatingInfo(Guid id)
        //{
        //    this._ratingTargetID = Guid.Empty;
        //    this._ratingOwnerID = Guid.Empty;
        //    this._ratingUserID = Guid.Empty;
        //    this._ratingComment = string.Empty;
        //    SqlDataReader reader = XPRatingUtility.SelectReader(id);
        //    if (reader.Read())
        //    {
        //        this.LoadFromReader(reader);
        //        reader.Close();
        //    }
        //    else
        //    {
        //        if (!reader.IsClosed)
        //        {
        //            reader.Close();
        //        }
        //        throw new ApplicationException("XPRatingInfo does not exist.");
        //    }
        //}

  
        protected void LoadFromReader(SqlDataReader reader)
        {
            if ((!Information.IsNothing(reader) && !reader.IsClosed))
            {
                this._ratingID = reader.GetGuid(0);
                this._ratingTargetID = reader.GetGuid(1);
                if (!reader.IsDBNull(2))
                {
                    this._ratingOwnerID = reader.GetGuid(2);
                }
                this._ratingUserID = reader.GetGuid(3);
                this._ratingSubject = reader.GetInt16(4);
                this._ratingValue = reader.GetInt16(5);
                this._ratingDate = reader.GetDateTime(6);
                if (!reader.IsDBNull(7))
                {
                    this._ratingComment = reader.GetString(7);
                }
            }
        }

        // Properties
        public string RatingComment
        {
            get { return this._ratingComment; }
            set { this._ratingComment = value; }
        }

        public DateTime RatingDate
        {
            get { return this._ratingDate; }
            set { this._ratingDate = value; }
        }

        public Guid RatingID
        {
            get { return this._ratingID; }
            set { this._ratingID = value; }
        }

        public Guid RatingOwnerID
        {
            get { return this._ratingOwnerID; }
            set { this._ratingOwnerID = value; }
        }

        public short RatingSubject
        {
            get { return this._ratingSubject; }
            set { this._ratingSubject = value; }
        }

        public Guid RatingTargetID
        {
            get { return this._ratingTargetID; }
            set { this._ratingTargetID = value; }
        }

        public Guid RatingUserID
        {
            get { return this._ratingUserID; }
            set { this._ratingUserID = value; }
        }

        public short RatingValue
        {
            get { return this._ratingValue; }
            set { this._ratingValue = value; }
        }


        // Fields
        private string _ratingComment;
        private DateTime _ratingDate;
        private Guid _ratingID;
        private Guid _ratingOwnerID;
        private short _ratingSubject;
        private Guid _ratingTargetID;
        private Guid _ratingUserID;
        private short _ratingValue;
    }


}
